//
//  ViewController.m
//  map
//
//  Created by mafeng on 16/8/13.
//  Copyright © 2016年 mafeng. All rights reserved.
//

#import "ViewController.h"
#import <MapKit/MapKit.h>
@interface ViewController ()<MKMapViewDelegate>
@property (weak, nonatomic) IBOutlet MKMapView *mapView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
//    _mapView.region = MKCoordinateRegionMake(CLLocationCoordinate2DMake(34.77274892, 113.67591140), MKCoordinateSpanMake(0.01, 0.01));
    
    _mapView.delegate = self;
    
    
}
- (IBAction)click:(id)sender {
    _mapView.region = MKCoordinateRegionMake(CLLocationCoordinate2DMake(31.2, 121.4), MKCoordinateSpanMake(30, 30));
    MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
    annotation.coordinate =  CLLocationCoordinate2DMake(31.2, 121.4);
    annotation.title = @"北京";
    annotation.subtitle = @"我来了";
    [_mapView addAnnotation:annotation];
    
}

- (IBAction)beijing:(id)sender {
  
  
}
-(MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation {
    
    MKAnnotationView *newAnnotation=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"annotation1"];
        newAnnotation.image = [UIImage imageNamed:@"Unknown-2.png"];
    // 可以让title显示出来
    newAnnotation.canShowCallout=YES;
    return newAnnotation;
}
//大头针视图被选中
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
    NSLog(@"大头针被选中");
}

// 地图定位功能


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
